﻿@using Logistics.Web.Models.Track
@model PlannedRouteModel
@using Telerik.Web.Mvc.UI
@using Nop.Core.Infrastructure

@{
    Layout = "~/Views/Shared/_Layout.Mobile.cshtml";
    //page title
    ViewBag.Title = @T("Logistics.Track.PlannedRouteList.Title").Text;
}

@if( Model.PackageLocations != null && Model.PackageLocations.Count > 0 )
{
    
<div>
    <div>
        @T("Logistics.Track.PlannedRouteList.Title") <span> : @T("Logistics.Track.Common.Fields.PlanId") @Model.PlanId.ToString()</span>
    </div>
</div>

<div id="planned-packages">
    <ul>
    @foreach (var PkgLoc in Model.PackageLocations) {
        if( PkgLoc.Rank.HasValue )
        {
            <li>
                <a href="/express/track/status/@PkgLoc.PackageId?plan=@Model.PlanId">
                    <div class="package">
                        <div class="packageid">
                            @PkgLoc.PackageId - <span class="status">@PkgLoc.ShippingStatus.ToString()</span> (@PkgLoc.AddressType)
                            (@if( PkgLoc.SamePickupLocationNumItems.HasValue )
                            {
                                @PkgLoc.SamePickupLocationNumItems.Value
                            }
                            else if( PkgLoc.SameDeliveryLocationNumItems.HasValue )
                            {
                                @PkgLoc.SameDeliveryLocationNumItems.Value
                            })
                        </div>

                        <div class="address">
                            @PkgLoc.Address.FormattedAddress
                        </div>
                        <div class="address">
                            @PkgLoc.Address.Company
                        </div>
                        @if (!String.IsNullOrEmpty(PkgLoc.Address.CellPhoneNumber))
                        {
                        <div class="address">
                            @PkgLoc.Address.CellPhoneNumber
                        </div>
                        }
                        @if (!String.IsNullOrEmpty(PkgLoc.Address.PhoneNumber))
                        {
                        <div class="address">
                            @PkgLoc.Address.PhoneNumber
                        </div>
                        }

                        @if (!String.IsNullOrEmpty(PkgLoc.Attribute))
                        {
                            @* TBI *@
                            <div class="address">
                                Attribute: @PkgLoc.Attribute
                            </div>   
                        }

                        @if (!String.IsNullOrEmpty(PkgLoc.Reference))
                        {
                            @* TBI *@
                            <div class="address">
                                Reference: @PkgLoc.Reference
                            </div>   
                        }
                
                        <div class="action" @if (PkgLoc.Action.Contains("(Completed)")) { <text>style="color:grey"</text> }>
                            @PkgLoc.Action
                        </div>
                    </div>
                </a>
            </li>
        }
    }
    </ul>
</div>

}
else
{
    if( Model.PackageLocations == null )
    {
        <div>No Planned Route Found</div>
    }
    else if( Model.PackageLocations.Count == 0 && Model.PlanId > 0)
    {
        <div>No Packages Found in Plan @Model.PlanId.ToString()</div>
    }   
}

<br />

@if( Model.AvailablePlanIds.Count > 0 )
{
    using (Html.BeginForm())
    {
        var TotalActivePlans = Model.AvailablePlanIds.Count - 1;

        <div>Active Plans (Total: @TotalActivePlans)</div>
        @Html.DropDownListFor(m => m.SelectedPlanId, Model.AvailablePlanIds)

        <div class="buttons">
            <input type="submit" name="confirm" class="t-button button-grey" value="@T("Common.Confirm")" />
        </div>
    }
}